from django.db.models import Count

from apps.post.models import Type, Topic


def get_context():
    return {
        'types': Type.objects.prefetch_related('posts').annotate(post_nums=Count('posts')).all(),
        'topics': Topic.objects.prefetch_related('posts').annotate(post_nums=Count('posts')).all(),
    }
